package com.fr.report;

import com.fr.base.ColumnRow;
import com.fr.base.core.FT;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLReadable;
import com.fr.base.xml.XMLableReader;
import java.io.Serializable;

public class ReportPageAttr
  implements XMLReadable, Serializable, Cloneable
{
  private static final long serialVersionUID = -4674402126987186258L;
  private static final int HEAD_ROW = 0;
  private static final int FOOT_ROW = 1;
  private static final int HEAD_COL = 2;
  private static final int FOOT_COL = 3;
  private FT[] repeatFTS = new FT[4];
  private boolean usePageFrozenColumn = false;
  private boolean usePageFrozenRow = false;

  public ReportPageAttr()
  {
    this.repeatFTS[0] = new FT(-1, -1);
    this.repeatFTS[1] = new FT(-1, -1);
    this.repeatFTS[2] = new FT(-1, -1);
    this.repeatFTS[3] = new FT(-1, -1);
  }

  public boolean isUnUsed()
  {
    FT localFT = new FT(-1, -1);
    for (int i = 0; i <= 3; ++i)
      if (!(localFT.equals(this.repeatFTS[i])))
        return false;
    return true;
  }

  public boolean isUsePageFrozenColumn()
  {
    return this.usePageFrozenColumn;
  }

  public void setUsePageFrozenColumn(boolean paramBoolean)
  {
    this.usePageFrozenColumn = paramBoolean;
  }

  public boolean isUsePageFrozenRow()
  {
    return this.usePageFrozenRow;
  }

  public void setUsePageFrozenRow(boolean paramBoolean)
  {
    this.usePageFrozenRow = paramBoolean;
  }

  public int getRepeatHeaderRowFrom()
  {
    return this.repeatFTS[0].from;
  }

  public void setRepeatHeaderRowFrom(int paramInt)
  {
    this.repeatFTS[0].from = paramInt;
  }

  public int getRepeatHeaderRowTo()
  {
    return this.repeatFTS[0].to;
  }

  public void setRepeatHeaderRowTo(int paramInt)
  {
    this.repeatFTS[0].to = paramInt;
  }

  public int getRepeatFooterRowFrom()
  {
    return this.repeatFTS[1].from;
  }

  public void setRepeatFooterRowFrom(int paramInt)
  {
    this.repeatFTS[1].from = paramInt;
  }

  public int getRepeatFooterRowTo()
  {
    return this.repeatFTS[1].to;
  }

  public void setRepeatFooterRowTo(int paramInt)
  {
    this.repeatFTS[1].to = paramInt;
  }

  public int getRepeatHeaderColumnFrom()
  {
    return this.repeatFTS[2].from;
  }

  public void setRepeatHeaderColumnFrom(int paramInt)
  {
    this.repeatFTS[2].from = paramInt;
  }

  public int getRepeatHeaderColumnTo()
  {
    return this.repeatFTS[2].to;
  }

  public void setRepeatHeaderColumnTo(int paramInt)
  {
    this.repeatFTS[2].to = paramInt;
  }

  public int getRepeatFooterColumnFrom()
  {
    return this.repeatFTS[3].from;
  }

  public void setRepeatFooterColumnFrom(int paramInt)
  {
    this.repeatFTS[3].from = paramInt;
  }

  public int getRepeatFooterColumnTo()
  {
    return this.repeatFTS[3].to;
  }

  public void setRepeatFooterColumnTo(int paramInt)
  {
    this.repeatFTS[3].to = paramInt;
  }

  public ColumnRow getFreezeColumnRow()
  {
    if ((this.usePageFrozenColumn) || (this.usePageFrozenRow))
      return ColumnRow.valueOf((this.usePageFrozenColumn) ? getRepeatHeaderColumnTo() + 1 : 0, (this.usePageFrozenRow) ? getRepeatHeaderRowTo() + 1 : 0);
    return null;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str1;
      String str2 = paramXMLableReader.getTagName();
      if ("HR".equals(str2))
      {
        if ((str1 = paramXMLableReader.getAttr("F")) != null)
          setRepeatHeaderRowFrom(Integer.parseInt(str1));
        if ((str1 = paramXMLableReader.getAttr("T")) != null)
          setRepeatHeaderRowTo(Integer.parseInt(str1));
      }
      else if ("FR".equals(str2))
      {
        if ((str1 = paramXMLableReader.getAttr("F")) != null)
          setRepeatFooterRowFrom(Integer.parseInt(str1));
        if ((str1 = paramXMLableReader.getAttr("T")) != null)
          setRepeatFooterRowTo(Integer.parseInt(str1));
      }
      else if ("HC".equals(str2))
      {
        if ((str1 = paramXMLableReader.getAttr("F")) != null)
          setRepeatHeaderColumnFrom(Integer.parseInt(str1));
        if ((str1 = paramXMLableReader.getAttr("T")) != null)
          setRepeatHeaderColumnTo(Integer.parseInt(str1));
      }
      else if ("FC".equals(str2))
      {
        if ((str1 = paramXMLableReader.getAttr("F")) != null)
          setRepeatFooterColumnFrom(Integer.parseInt(str1));
        if ((str1 = paramXMLableReader.getAttr("T")) != null)
          setRepeatFooterColumnTo(Integer.parseInt(str1));
      }
      else if ("UPFCR".equals(str2))
      {
        if ((str1 = paramXMLableReader.getAttr("COLUMN")) != null)
          setUsePageFrozenColumn(Boolean.valueOf(str1).booleanValue());
        if ((str1 = paramXMLableReader.getAttr("ROW")) != null)
          setUsePageFrozenRow(Boolean.valueOf(str1).booleanValue());
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("HR");
    if (this.repeatFTS[0].from >= 0)
      paramXMLPrintWriter.attr("F", this.repeatFTS[0].from);
    if (this.repeatFTS[0].to >= 0)
      paramXMLPrintWriter.attr("T", this.repeatFTS[0].to);
    paramXMLPrintWriter.end();
    paramXMLPrintWriter.startTAG("FR");
    if (this.repeatFTS[1].from >= 0)
      paramXMLPrintWriter.attr("F", this.repeatFTS[1].from);
    if (this.repeatFTS[1].to >= 0)
      paramXMLPrintWriter.attr("T", this.repeatFTS[1].to);
    paramXMLPrintWriter.end();
    paramXMLPrintWriter.startTAG("HC");
    if (this.repeatFTS[2].from >= 0)
      paramXMLPrintWriter.attr("F", this.repeatFTS[2].from);
    if (this.repeatFTS[2].to >= 0)
      paramXMLPrintWriter.attr("T", this.repeatFTS[2].to);
    paramXMLPrintWriter.end();
    paramXMLPrintWriter.startTAG("FC");
    if (this.repeatFTS[3].from >= 0)
      paramXMLPrintWriter.attr("F", this.repeatFTS[3].from);
    if (this.repeatFTS[3].to >= 0)
      paramXMLPrintWriter.attr("T", this.repeatFTS[3].to);
    paramXMLPrintWriter.end();
    if ((this.usePageFrozenColumn) || (this.usePageFrozenRow))
    {
      paramXMLPrintWriter.startTAG("UPFCR");
      paramXMLPrintWriter.attr("COLUMN", this.usePageFrozenColumn).attr("ROW", this.usePageFrozenRow);
      paramXMLPrintWriter.end();
    }
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    ReportPageAttr localReportPageAttr = (ReportPageAttr)super.clone();
    localReportPageAttr.repeatFTS[0] = ((FT)this.repeatFTS[0].clone());
    localReportPageAttr.repeatFTS[1] = ((FT)this.repeatFTS[1].clone());
    localReportPageAttr.repeatFTS[2] = ((FT)this.repeatFTS[2].clone());
    localReportPageAttr.repeatFTS[3] = ((FT)this.repeatFTS[3].clone());
    return localReportPageAttr;
  }
}